Repository navigation
feat: add RavenDB Cloud hosting integration - #2413
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 2413Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 2413" |
There was a problem hiding this comment.
🟡 Changes recommended
Database-existence checks can wrongly trigger creation and block startup, while certificate aliasing and identifier collisions can cause HTTPS validation failures or deliver another product’s credentials.
5 open issues
Compose certificate variable names can collide · New Sharded databases are misdetected as missing · New Permission-filtered pagination can trigger unauthorized database creation · New Custom connection aliases omit required RavenDB certificates · New Auto-grown disks cannot be redeployed at their current size · New
1 file not reviewed
examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/package-lock.json: Generated file
What changed in this PR
Adds a preview RavenDB Cloud deployment integration alongside the existing local-container integration, addressing #2412. Docker Compose applications receive cluster URLs and individual client certificates while local development remains container-based.
Changes:
- Adds managed and attached Cloud deployments, planning, approval checks, certificate rotation, and guarded teardown.
- Extends RavenDB hosting and client support for deployment strategies, certificate configuration, and multiple node URLs.
- Adds tests, C# and TypeScript examples, documentation, and package ownership.
| File | Description |
|---|---|
| tests/CommunityToolkit.Aspire.RavenDB.Client.Tests/RavenDBClientConnectionStringTests.cs | Tests multi-node connection strings. |
| tests/CommunityToolkit.Aspire.RavenDB.Client.Tests/RavenDBClientCertificateTests.cs | Tests certificate configuration and errors. |
| tests/CommunityToolkit.Aspire.RavenDB.Client.Tests/AspireRavenDBExtensionsTests.cs | Tests reuse of existing databases. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Tests/RavenDBPublishStrategyTests.cs | Tests alternate publishing behavior. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/TypeScriptAppHostTests.cs | Exercises TypeScript publishing and planning. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/RavenDBConsumersTests.cs | Tests consumer discovery and certificate settings. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/RavenDBCloudPublishTests.cs | Tests deployment pipeline behavior and safeguards. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/RavenDBCloudProductsTests.cs | Tests product lifecycle and certificate rotation. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/RavenDBCloudPlanTests.cs | Tests planning and configuration validation. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/Fakes.cs | Provides in-memory deployment test dependencies. |
| tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests.csproj | Defines the Cloud test project. |
| src/Shared/RavenDB/RavenDBConsumers.cs | Discovers referencing applications and databases. |
| src/Shared/RavenDB/RavenDBClientConfiguration.cs | Delivers certificate configuration to consumers. |
| src/CommunityToolkit.Aspire.RavenDB.Client/README.md | Documents certificates and cluster URLs. |
| src/CommunityToolkit.Aspire.RavenDB.Client/RavenDBClientSettings.cs | Adds base64 certificate configuration. |
| src/CommunityToolkit.Aspire.RavenDB.Client/RavenDBClientExtension.cs | Updates URL parsing and database existence checks. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB/README.md | Introduces the Cloud deployment option. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB/RavenDBServerResource.cs | Exposes deployment strategy and database metadata. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB/RavenDBPublishStrategy.cs | Adds alternate publishing and wait removal. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB/RavenDBBuilderExtensions.cs | Records databases requiring creation. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/README.md | Documents deployment, security, and limitations. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBServerAdministration.cs | Implements server administration operations. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudValues.cs | Models deploy-time URLs and certificates. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudSpec.cs | Defines explicit product specifications. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudProducts.cs | Implements provisioning and guarded termination. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudPlan.cs | Validates specifications and plans changes. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudPipelineSteps.cs | Coordinates deployment and destroy steps. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudOptions.cs | Defines Cloud options and enums. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudEnvironment.cs | Reads deployment process environment settings. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudDeployment.cs | Holds deployment configuration and state. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudCertificates.cs | Issues and revokes application certificates. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudBuilderExtensions.cs | Adds managed and attached publishing APIs. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/RavenDBCloudApiClient.cs | Implements Cloud API requests and retries. |
| src/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.csproj | Defines the preview hosting package. |
| README.md | Adds the Cloud integration to the catalog. |
| examples/ravendb/RavenDB.Cloud.AppHost/Properties/launchSettings.json | Configures local example launch settings. |
| examples/ravendb/RavenDB.Cloud.AppHost/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.csproj | Defines the C# example project. |
| examples/ravendb/RavenDB.Cloud.AppHost/AppHost.cs | Demonstrates Cloud publishing in C#. |
| examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/tsconfig.json | Configures TypeScript compilation. |
| examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/package.json | Defines example dependencies and scripts. |
| examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/eslint.config.mjs | Checks asynchronous AppHost calls. |
| examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/aspire.config.json | Configures Aspire and integration references. |
| examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/apphost.mts | Demonstrates Cloud publishing in TypeScript. |
| docs/diagnostics.md | Documents the experimental hosting API diagnostic. |
| CommunityToolkit.Aspire.slnx | Registers the package, tests, and C# example. |
| CODEOWNERS | Updates RavenDB ownership and covers Cloud files. |
Review effort: Balanced
|
|
||
| /// <summary>An application's client certificate, as base64-encoded .pfx content.</summary> | ||
| internal sealed class RavenDBCloudCertificate(RavenDBServerResource server, IResource consumer) | ||
| : RavenDBCloudDeployTimeValue($"{{{server.Name}-{consumer.Name}.certificate}}") |
There was a problem hiding this comment.
Fixed: the AppHost now stops before anything runs when two deploy-time values would share a Docker Compose variable, and the error names both resources. Covered by ValuesThatWouldShareAComposeVariableAreAnError.
| { | ||
| var names = documentStore.Maintenance.Server.Send(new GetDatabaseNamesOperation(start, pageSize)); | ||
|
|
||
| if (names.Any(name => string.Equals(name, databaseName, StringComparison.OrdinalIgnoreCase))) |
There was a problem hiding this comment.
Fixed: the client now asks the server about that one database (GET /databases?name=...), which finds a sharded database by its own name and needs no permission beyond access to that database. AddRavenDbClient_CreateDatabaseUsesAnExistingShardedDatabase reproduces the failure with the previous check and passes now.
| if (names.Length < pageSize) | ||
| { | ||
| return false; |
There was a problem hiding this comment.
Fixed by the same change: looking up one database involves no paging, so permission filtering cannot hide it. The client tests run against an unsecured embedded server, so a restricted certificate cannot be reproduced there; a deployment to RavenDB Cloud in which the application starts with CreateDatabase = true and a certificate limited to its own database passes with the new check.
| continue; | ||
| } | ||
|
|
||
| connectionNames.Add(referenced.Name); |
There was a problem hiding this comment.
Fixed: the certificate now goes under the names the application gets the server's connection strings by, read from the environment WithReference writes, so a connection renamed with connectionName gets it too. Covered by WithSeveralServersTheCertificateGoesUnderTheConnectionNamesOnly.
|
|
||
| var sizes = type.Parameters?.AvailableDiskSizes?.Where(s => s > 0).ToList() ?? []; | ||
|
|
||
| if (sizes.Count > 0 && !sizes.Contains(spec.DiskSizeInGb)) |
There was a problem hiding this comment.
Fixed: the instance type's offered sizes are checked only when creating a product. An existing disk keeps its size, including one RavenDB Cloud grew past that list, never shrinks, and grows only to the sizes RavenDB Cloud lists for that disk (availableDiskSizes in the product details). Covered by DiskRavenDBCloudGrewIsNoChange and DiskGrowsOnlyToTheSizesRavenDBCloudListsForIt.
20ec1f7 to
07f2c2a
Compare
07f2c2a to
bf920e7
Compare
Adds CommunityToolkit.Aspire.Hosting.RavenDB.Cloud (preview): aspire deploy creates or finds a RavenDB Cloud product and gives every application that references the RavenDB server the product's node URLs and a client certificate of its own; aspire run keeps the local container. - Hosting.RavenDB: an experimental publish strategy API (CTASPIRERAVENDB001) the Cloud package plugs into. - RavenDB.Client: a certificate as a value (CertificateBase64), several node URLs in the connection string, and CreateDatabase that works with a certificate scoped to its own database. - CODEOWNERS: the RavenDB owners are ppekrol, poissoncorp and karmeli87.
bf920e7 to
6198266
Compare
|
@aaronpowell this is ready for review: the RavenDB code owners approved, and CI is green apart from two runner failures outside RavenDB (Dapr container networking on Ubuntu, the Kind tests on Windows). |


Closes #2412
Adds
CommunityToolkit.Aspire.Hosting.RavenDB.Cloud(preview):aspire deploycreates or finds a RavenDB Cloud product and hands every application that references the RavenDB server the product's node URLs and a client certificate of its own.aspire runkeeps the local container.What changes where
[Experimental("CTASPIRERAVENDB001")]and documented indocs/diagnostics.md:WithPublishStrategypublishes the server with a deployment package's URL instead of its container, andRavenDBServerResource.PublishStrategyandDatabasesToCreateexpose what a deployment needs. AppHosts never call it, and the base package uses no experimental Aspire API.CertificateBase64, so a certificate can arrive as a value (an environment variable) instead of a file;CreateDatabasechecks that the database exists by listing the databases the certificate may access, so an application whose certificate only reaches its own database still starts; the connection string'sURLmay list a cluster's nodes separated by commas.PublishAsRavenDBCloud, the AppHost owns the product and its spec) and attached (PublishAsExistingRavenDBCloud) modes;.envfile;aspire destroyterminates the product only withTerminateOnDestroy, and refuses a product that does not match the AppHost.Testing
PlanAgainstTheCloudApiplans the TypeScript example against the real Cloud API. Like the other tests that need an authenticated external service, it is markedRequiresAuthenticatedTooland skipped on CI; locally it runs whenRAVENDB_CLOUD_API_KEYis set.PR Checklist
Other information
RavenDBClientSettings.CertificateBase64in the client and by the experimental deployment API in the hosting package; theapi/*.csbaselines are left to the repository's tooling.